/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.RoleDAOInterface;
import org.cuatrovientos.erp.model.Role;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author pablo_guerrero
 * This class implements RoleBOInterface
 *
 */
public class RoleBO implements RoleBOInterface{
	// Get log4j logger
	private static final Logger logger = Logger.getLogger(RoleBO.class);
	
	@Autowired
    private RoleDAOInterface roleDAO;
	
	/**
 	 * @param int id
 	 * @return Role role
 	 * This method returns a role selected by it's id
 	 */
	@Override
	public Role selectById(int id) {
		logger.info("selectById: " + id);
		return roleDAO.selectById(id);
	}
	
	/**
	 * @return All the roles we have in the database
	 */
	@Override
	public List<Role> selectAll() {
		logger.info("selectAll: ");
		return roleDAO.selectAll();
	}
	
	/**
	 * @return The number of roles we have in the database
	 */
	@Override
	public List<Role> search(String name) {
		logger.info("search : " + name);
		return roleDAO.search(name);
	}
	
	/**
	 * @param int id
	 * This method deletes the role selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		roleDAO.deleteById(id);
	}
	
	/**
	 * @param Role role
	 * This method insert a role in the database passed by parameter
	 */
	@Override
	public void insert(Role role) {
		logger.info("insert: " + role);
		roleDAO.insert(role);
	}
	
	/**
	 * @param Role role
	 * This method updates a role passed by parameter
	 */
	@Override
	public void update(Role role) {
		logger.info("update: " + role);
		roleDAO.update(role);
	}
	
	/**
	 * @param Role role
	 * This method deletes a role passed by parameter
	 */
	@Override
	public void delete(Role role) {
		logger.info("delete: " + role);
		roleDAO.delete(role);
	}

}
